﻿@{
    ViewBag.Title = "course";
    List<LeEdu.MODEL.Estimate> esti = ViewBag.esti;
    LeEdu.BLL.EstimateBLL estibll = new LeEdu.BLL.EstimateBLL();
    LeEdu.MODEL.UserInfo user = (LeEdu.MODEL.UserInfo)Session["User"];
    LeEdu.MODEL.Estimate es = estibll.getEntity(t => t.UserInfoId == user.UserInfoId);
}


<script src="~/Content/http%20_zhishile.sea.js"></script>
<link href="~/Content/Site.css" rel="stylesheet" />
<link href="~/Content/zhishile.css%206.9.6.css" rel="stylesheet" />
<script src="~/Content/zhishile.config.js"></script>
<link href="~/Content/zhishile.icon.css%206.9.6.css" rel="stylesheet" />
<link href="~/Content/zhishile.main.css%206.9.6.css" rel="stylesheet" />
<link href="~/Content/zhishile.min.css%206.9.6.css" rel="stylesheet" />
<script src="~/Content/zhishile.style.js"></script>
<link href="~/Content/css/stylesheet.css" rel="stylesheet" />
<script type="text/javascript" charset="utf-8" src="~/Content/js/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="~/Content/js/jquery.raty.min.js"></script>







<div id="main">

    @*课程分布视图*@
    @Html.Partial("Front-Partial1")
    <div id="detailContent">
        <div class="detailContentLeft-tags">
            <a href="/Home/ClassHour/@ViewBag.course.CoursesId">
                <div id="videoSelect" class="detailContentLeft-video-tag">视频教程</div>
            </a>
            <a href="/Home/question">
                <div id="questionSelect" class="detailContentLeft-video-tag">互动问答</div>
            </a>
            <a href="/Home/download">
                <div id="detail-resource-tab" class="detailContentLeft-video-tag">资源下载</div>
            </a>
            <a href="/Home/ShowNotes">
                <div id="detail-resource-tab" class="detailContentLeft-video-tag">笔记</div>
            </a>
            <a href="/Home/Estimat">
                <div id="estimate" class="detailContentLeft-video-tagSelect">评价</div>
            </a>
            <a href="/Home/topics">
                <div id="estimate" class="detailContentLeft-video-tag">话题</div>
            </a>
        </div>
        <!--呈现某个系列课程的具体评价页面-->
        <div id="detailContentLeft-video-list">
            <div id="detailContentLeft" >
                <section class="es-section">
                    <div class="clearfix">
                        <button id="ss" onclick="cx()" style="margin-top:20px; @(es==null?"display: none":"")" class="btn btn-primary btn-sm pull-right js-show-review-form">重新评价</button>
                    </div>
                    <div id="yin" style="@(es!=null?"display: none":"")">
                        @*<form data-widget-cid="widget-0" novalidate="novalidate" id="review-form" method="post" action="/course/125/review/create" style="display:none;">*@
                        <form data-widget-cid="widget-0" novalidate="novalidate" id="review-form" method="post">
                            <div class="form-group controls">
                                请打分：
                                <input type="hidden" name="UserInfoId"  value="@Convert.ToInt32(Session["id"])" />
                                <input type="hidden" name="CoursesID" value="@ViewBag.course.CoursesId" />
                                <div id="fixed"></div>
                                
                                <script type="text/javascript">
                                     //socr=0;
                                 var socr =@(es != null ? es.Score : 0)
                                    $('#fixed').raty({
                                        path: "/Content/images",
                                        starOff: 'star-off.png',
                                        starOn: 'star-on.png',
                                        size: 24,
                                        hints: ['差', '中', '良', '优', '棒'],
                                        score: socr,
                                        click: function (score, evt) {
                                
                                            $('#fen').val(score);
                                    }
                                    });
                                </script>
                             

                                <input type="hidden" id="ID" name="ID" value="@if(es!=null){@es.ID}" />
                                <input type="hidden" id="fen" name="Score" />
                                <input data-explain="" data-widget-cid="widget-1" name="rating" value="3" type="hidden">
                                <div class="help-block" style="display:none;"></div>
                            </div>
                            <div class="form-group controls">
                                <textarea cols="120" rows="12" property="评价详细内容" name="EstimateContent" id="EstimateContent"> @if (es != null){@es.EstimateContent} </textarea>
                                <div class="help-block" style="display:none;"> </div>
                            </div>
                        </form>

                        <div class="form-group clearfix">
                            <span class="text-success pull-left" style="display: none;">评价已保存！</span>
                            <button id="bc" onclick="bc()" type="button" class="btn btn-primary pull-right" data-loading-text="正在保存..." >保存</button>
                            <button id="qx" onclick="qx()" class="btn btn-link pull-right js-hide-review-form" type="button">取消</button>
                        </div>
                        <input name="_csrf_token" value="8ff404fdac9d5044b9581189134d38614e24949a" type="hidden">
                    </div>
                    @foreach (var item in esti)
                    {
                        <div class="js-reviews">
                            <div class="media media-evaluate">
                                <div class="media-left">
                                    <a title="" data-original-title="" class=" js-user-card" href="/user/4" data-card-url="/user/4/card/show" data-user-id="4">
                                        <img class="img-thumbnail img-circle" style="width:40px;height:40px" src="~/Img/@item.UserInfo.Avatar">
                                    </a>

                                </div>
                                <div class="media-body">
                                    <div class="title">
                                        <a class="link-light " href="/user/4">@item.UserInfo.Uname</a>
                                        @item.EstimateTime
                                    </div>
                                    <div id="@item.ID"></div>
                                    <script type="text/javascript">
                                        var aaa=@item.Score
                                        $('#@item.ID').raty({
                                            path: "/Content/images",
                                            starOff: 'star-off.png',
                                            starOn: 'star-on.png',
                                            size: 24,
                                            hints: ['差', '中', '良', '优', '棒'],
                                            readOnly: true,//只能读不能改
                                            score: aaa
                                        });
                                    </script>
                                    <div class="content">
                                        <div class="short-content">@item.EstimateContent</div>
                                        <div class="full-content" style="display:none;">@item.EstimateContent</div>
                                    </div>

                                </div>
                            </div>
                        </div>

                    }

                </section>

            </div>
            @*讲师介绍局部视图*@
                        @Html.Partial("Fronr-Partial2")
      
            <div class="clearBoth"></div>
        </div>
        <div id="scourse-forbid-dialog" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" data-backdrop="static">
            <div class="modalTitleContent">
                <div class="modalTitle">提示</div>
                <div class="modalCloseButton"></div>
                <div class="clearBoth"></div>
            </div>
            <div id="scourse-forbid-content">
                <div class="notice16" id="scourse-forbid-title">
                    你尚未购买本课程，请购买后观看
                </div>
                <div class="mbtn bluebtn" id="scourse-forbid-button">知道了</div>
            </div>
        </div>
    </div>
    <input type="hidden" value="40" id="courseID">
</div>
@*<script>
   
       
        function bc() {

            $('#ss').css("visibility", "visible");
            $('#review - form').css("visibility", "hidden");
            $('#bc').css("visibility", "hidden");
            $('#qx').css("visibility", "hidden");
        }



</script>*@


<script>
    //重新评论按钮
    function cx() {

        $('#ss').css("display","none");
        $('#yin').css("display","");
    }
    //取消评论
    function qx() {

        $('#ss').css("display", "");
        $('#yin').css("display", "none");
    }
    //添加评论
    function bc() {
        if ($('#ID').val() == null || $('#ID').val()==0) {
            
            var f = $('#review-form').serialize();
            $.post('/Home/Estimats', f, function (data) {
                if (data == 1) {
                    alert('评论成功！');
                    location.href = '/Home/Estimat'
                }
                else {
                    alert('评论失败！');
                }
            })

        }
        else {
            var f = $('#review-form').serialize();
            $.post('/Home/Estimatcx', f, function (data) {
                if (data == 1) {
                    alert('评论成功！');
                   location.href = '/Home/Estimat'
                }
                else {
                    alert('评论失败！');
                }
            })
        }
    }
    

</script>